/*
 * Project: chapter5
 * File Created: Saturday, 13th November 2021 10:28:41 am
 * Author: hotsuitor (hotsuitor@qq.com)
 * -----
 * Last Modified: Sunday, 14th November 2021 11:54:27 am
 * Modified By: hotsuitor (hotsuitor@qq.com)
 */
package main

import (
	pb "chapter5/protobuf"
	"fmt"
	"log"

	"golang.org/x/net/context"
	"google.golang.org/grpc"
)

func main() {
	conn, err := grpc.Dial(":8078", grpc.WithInsecure())
	if err != nil {
		log.Fatal("dial error: %v\n", err)
	}

	defer conn.Close()

	// 实例化 ProgrammerService
	client := pb.NewProgrammerServiceClient(conn)

	// 调用服务
	req := new(pb.Request)
	req.Name = "lili"
	resp, err := client.GetProgrammerInfo(context.Background(), req)
	if err != nil {
		log.Fatal("resp error: %v\n", err)
	}

	fmt.Printf("Received: %v\n", resp)
}
